﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable()> Public Class MaxiFile
    Implements ICloneable
    Private m_PolluteName As String
    Private m_GroupName As String
    Private m_AervarageTime As String
    Private m_Maxi As Double = 0.5
    Private m_FileName As String
    ''' <summary>
    ''' 污染物名称
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property PolluteName() As String
        Get
            Return m_PolluteName
        End Get
        Set(ByVal value As String)
            m_PolluteName = value
        End Set
    End Property
    ''' <summary>
    ''' 污染源分组
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property GroupName() As String
        Get
            Return m_GroupName
        End Get
        Set(ByVal value As String)
            m_GroupName = value
        End Set
    End Property
    ''' <summary>
    ''' 平均时间
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property AervarageTime() As String
        Get
            Return m_AervarageTime
        End Get
        Set(ByVal value As String)
            m_AervarageTime = value
        End Set
    End Property
    ''' <summary>
    ''' 浓度限值 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property Maxi() As Double
        Get
            Return m_Maxi
        End Get
        Set(ByVal value As Double)
            m_Maxi = value
        End Set
    End Property
    ''' <summary>
    ''' 对应的文件名和路径
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property FileName() As String
        Get
            Return m_FileName
        End Get
        Set(ByVal value As String)
            m_FileName = value
        End Set
    End Property


    Public Function OutPutMaxiFile(ByVal Control As Control, ByVal Groups As Groups) As String
        Dim GroupId As String = ""
        For i As Integer = 0 To Groups.ArrayGroup.Length - 1
            If Groups.ArrayGroup(i).Name = Me.m_GroupName Then
                GroupId = Groups.ArrayGroup(i).GroupID
            End If
        Next
        Dim Time As String = ""
        For i As Integer = 0 To Control.AerageingTime.GetSelectedAerageingTime.Length - 1
            If Control.AerageingTime.GetSelectedAerageingTime(i) = Me.m_AervarageTime Then
                Time = Control.AerageingTime.GetSelectedAerageingTimeToAREMOD(i)
            End If
        Next
        Dim strO As String = ""
        strO = strO & "OU MAXIFILE  " & Time & "  " & GroupId & "  " & Me.m_Maxi * 1000 & "  " & Me.m_FileName & vbCrLf
        Return strO
    End Function


    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New MaxiFile
        obj.m_PolluteName = Me.m_PolluteName
        obj.m_GroupName = Me.m_GroupName
        obj.m_AervarageTime = m_AervarageTime
        obj.m_Maxi = m_Maxi
        obj.m_FileName = m_FileName
        Return obj
    End Function
End Class
